var util = require('../../utils/util.js')
var app = getApp();
var md5 = require('../md5.js');
Page({
  data: {
    currentTab: 0,
    showModal: false,
    yycgshow: false,
    sfyyshow: false,
    sfxyyyshow: true,
    cureventid: '',
    gxhrcMesg:[],
    interval:'',
    countdown:{
        day: '',
        hour: '',
        minute: '',
        second: ''
    },
    dateSelectItems: [{
      id: '12',
        "week": "周一",
        "date": '18',
        active: true,
      },
      {
        id: '13',

        "week": "周二",
        "date": '19',
      },
      {
        id: '14',

        "week": "周三",
        "date": '20',
      },
      {
        id: '15',

        "week": "周四",
        "date": '21',
      },
      {
        id: '16',
        "week": "周五",
        "date": '22',
      },
    ],
    personalDateSelectItems: [{
      id: '12',
        "week": "周一",
        "date": '18',
        active: true,
      },
      {
        id: '13',

        "week": "周二",
        "date": '19',
      },
      {
        id: '14',

        "week": "周三",
        "date": '20',
      },
      {
        id: '15',

        "week": "周四",
        "date": '21',
      },
      {
        id: '16',
        "week": "周五",
        "date": '22',
      },
    ],
  },
  submit: function () {
    this.setData({
      showModal: true
    })
  },
  onPullDownRefresh: function(){
    wx.stopPullDownRefresh({
      complete: (res) => {},
    });
  },
  //底部导航跳转
  toAiIndex: function () {
    util.toAiIndex()
  },
  toContactsIng: function () {
    util.toContactsIng()
  },
  toProductRevision: function () {
    util.toProductRevision()
  },
  toMy: function () {
    util.toMy()
  },
  toBadge: function () {
    util.toBadge()
  },
  preventTouchMove: function () {

  },
  startCountdown: function (serverTime, endTime) {
    var that = this;
    //var date = "2020-04-21 09:00:00"
    endTime = new Date(endTime.replace(/-/g, '/'));
    
    serverTime = new Date(serverTime);
    var millisecond = endTime.getTime() - serverTime.getTime();
     
    that.data.interval = setInterval(function () {
      console.log('循环中');
      millisecond -= 1000;
      if (millisecond <= 0){
        clearInterval(that.data.interval);
        that.setData({
          countdown: {
            day: '00',
            hour: '00',
            minute: '00',
            second: '00'
          }
        });
        return;
      }
      that.transformRemainTime(millisecond);
    }, 1000);
  },
  // 剩余时间(毫秒)处理转换时间
  transformRemainTime: function (millisecond) {
    var that = this;
    var countdownObj = that.data.countdown;
    // 秒数
    var seconds = Math.floor(millisecond / 1000);
    // 天数
    countdownObj.day = that.formatTime(Math.floor(seconds / 3600 / 24));
    // 小时
    countdownObj.hour = that.formatTime(Math.floor(seconds / 3600 % 24));
    // 分钟
    countdownObj.minute = that.formatTime(Math.floor(seconds / 60 % 60));
    // 秒
    countdownObj.second = that.formatTime(Math.floor(seconds % 60));
    that.setData({
      countdown: countdownObj
    });
  },
  //格式化时间为2位
  formatTime: function(time){
    if(time < 10)
      return '0' + time;
    return time;
  },
  sendMesg: function (e) {
    var mesg = e.detail.value
    var that = this;
    //设置语言0:中文，1：英文
    var setlanguage = wx.getStorageSync('setlanguage')
    if ((wx.getStorageSync('setlanguage') || !"".trim() == wx.getStorageSync('setlanguage'))) {
      this.setData({
        setlanguage: wx.getStorageSync('setlanguage')
      })
    } else {
      wx.setStorageSync('setlanguage', 0);
      this.setData({
        setlanguage: 0
      })
    }
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
      && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
      
      wx.navigateTo({
        url: '../conferenceSchedule/scheduleDetails?keyword=' + mesg,
      })



    } else {
      wx.redirectTo({
        url: '../signInbyPhone/signIn'
      })
    }
  },
  onLoad: function (options) {
    var that = this;
    // 页面初始化 options为页面跳转所带来的参数
    var currentTab = options.currentTab
    if (currentTab || !"".trim() == currentTab) {
      that.setData({
        currentTab: currentTab
      }) 
    }
    //获取缓存展会id和用户id存在则获取最新联系人列表
    //设置语言0:中文，1：英文
    var setlanguage = wx.getStorageSync('setlanguage')
    if ((wx.getStorageSync('setlanguage') || !"".trim() == wx.getStorageSync('setlanguage'))) {
      this.setData({
        setlanguage: wx.getStorageSync('setlanguage')
      })
      if (setlanguage == 1) {
        wx.setNavigationBarTitle({
          title: 'Conference schedule'
        })
      } else {
        wx.setNavigationBarTitle({
          title: '会议日程'
        })
      }
    } else {
      wx.setStorageSync('setlanguage', 0);
      this.setData({
        setlanguage: 0
      })
    }
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    console.log('exhibitionid=' + exhibitionid)
    console.log('u=' + u)
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
      && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/schedule/list'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["u"] = u

      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          var curscheduleid=''
          for (var index in curdata) {
            var scheduleid = curdata[index].scheduleid
            if (curdata[index].currentdate) {
              curscheduleid = scheduleid
            } 
          }  
          that.setData({
            rcMesg: curdata,
            curscheduleid: curscheduleid
          });
        }, fail: res => {
          console.log(res, "error")
        }

      })
      //加载个性化日程
      var gxhurl = app.globalData.picoaddress + '/attendee/schedule/mycollection'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: gxhurl,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          var curgxhscheduleid = ''
          var gxhrcleg ='0' //默认为null
          for (var index in curdata) {
            //判断个性化日程是否为null
            var sjleg = curdata[index].eventgroup.length
            console.log('sjleg='+sjleg)
            if(sjleg>0){
              gxhrcleg='1'
            }
            var scheduleid = curdata[index].scheduleid
            if (curdata[index].currentdate) {
              curgxhscheduleid = scheduleid
            }
          }
          that.setData({
            gxhrcleg:gxhrcleg,
            gxhrcMesg: curdata,
            curgxhscheduleid: curgxhscheduleid
          });
        }, fail: res => {
          console.log(res, "error")
        }

      })
    } else {
      wx.redirectTo({
        url: '../signInbyPhone/signIn'
      })
    }
  },
  onShow: function () {
    var that = this;
    // 页面初始化 options为页面跳转所带来的参数
    var currentTab = that.data.currentTab
    
    //获取缓存展会id和用户id存在则获取最新联系人列表
    //设置语言0:中文，1：英文
    var setlanguage = wx.getStorageSync('setlanguage')
    if ((wx.getStorageSync('setlanguage') || !"".trim() == wx.getStorageSync('setlanguage'))) {
      this.setData({
        setlanguage: wx.getStorageSync('setlanguage')
      })
      if (setlanguage == 1) {
        wx.setNavigationBarTitle({
          title: 'Conference schedule'
        })
      } else {
        wx.setNavigationBarTitle({
          title: '会议日程'
        })
      }
    } else {
      wx.setStorageSync('setlanguage', 0);
      this.setData({
        setlanguage: 0
      })
    }
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    console.log('exhibitionid=' + exhibitionid)
    console.log('u=' + u)
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
      && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/schedule/list'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["u"] = u

      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          var curscheduleid = that.data.curscheduleid    
          for (var index in curdata) {
            var scheduleid = curdata[index].scheduleid
            if (curscheduleid == scheduleid) {
              curdata[index].currentdate = true
            } else {
              curdata[index].currentdate = false
            }
          }
          that.setData({
            rcMesg: curdata,
        //    curscheduleid: curscheduleid
          });
        }, fail: res => {
          console.log(res, "error")
        }

      })
      //加载个性化日程
      var gxhurl = app.globalData.picoaddress + '/attendee/schedule/mycollection'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: gxhurl,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          var curgxhscheduleid = that.data.curgxhscheduleid
          var gxhrcleg ='0' //默认为null
          for (var index in curdata) {
             //判断个性化日程是否为null
             var sjleg = curdata[index].eventgroup.length
             console.log('sjleg='+sjleg)
             if(sjleg>0){
               gxhrcleg='1'
             }
            var scheduleid = curdata[index].scheduleid
            if (curgxhscheduleid == scheduleid) {
              curdata[index].currentdate = true
            } else {
              curdata[index].currentdate = false
            }
          }
          that.setData({
            gxhrcleg:gxhrcleg,
            gxhrcMesg: curdata,
           // curgxhscheduleid: curgxhscheduleid
          });
        }, fail: res => {
          console.log(res, "error")
        }

      })
    } else {
      wx.redirectTo({
        url: '../signInbyPhone/signIn'
      })
    }
  },

  sc: function (e) {
    var that = this
    var eventid = e.currentTarget.dataset.tagid
    var curscheduleid = that.data.curscheduleid
    var curgxhscheduleid = that.data.curgxhscheduleid
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    console.log('exhibitionid=' + exhibitionid)
    console.log('u=' + u)
    if (!(exhibitionid=='0' && u=='0')) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/schedule/collection'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["eventid"] = eventid
      k["u"] = u
      var sign = app.globalData.picotoken + 'clientios' + 'eventid' + eventid +'exhibitionid' + exhibitionid +  'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          //从新加载数据刷新
          if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
            && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
            //默认最新（调用pico接口）
            var timestamp = Date.parse(new Date());
            timestamp = timestamp / 1000;
            var url = app.globalData.picoaddress + '/attendee/schedule/list'
            var k = {}
            k["v"] = '1.0.0'
            k["client"] = 'ios'
            k["timestamp"] = timestamp
            k["lan"] = 'cn'
            k["exhibitionid"] = exhibitionid
            k["u"] = u

            var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
            console.log(sign)
            var curb64 = md5.hexMD5(sign)
            console.log(curb64)
            k["sign"] = curb64
            wx.request({
              header: {
                'content-type': 'application/x-www-form-urlencoded',
              },
              url: url,
              method: 'post',
              data: k,
              success(res) {
                console.log(res)
                var mesg = res.data
                console.log('mesg=' + mesg)
                var curdata = mesg.data
                for (var index in curdata) {
                  var scheduleid = curdata[index].scheduleid
                  if (curscheduleid == scheduleid) {
                    curdata[index].currentdate = true
                  } else {
                    curdata[index].currentdate = false
                  }
                }
                that.setData({
                  rcMesg: curdata
                });
              }, fail: res => {
                console.log(res, "error")
              }

            })

            //加载个性化日程
            var gxhurl = app.globalData.picoaddress + '/attendee/schedule/mycollection'
            wx.request({
              header: {
                'content-type': 'application/x-www-form-urlencoded',
              },
              url: gxhurl,
              method: 'post',
              data: k,
              success(res) {
                console.log(res)
                var mesg = res.data
                console.log('mesg=' + mesg)
                var curdata = mesg.data
              //  var curgxhscheduleid = ''
                var gxhrcleg ='0' //默认为null
                for (var index in curdata) {
                  //判断个性化日程是否为null
                  var sjleg = curdata[index].eventgroup.length
                  console.log('sjleg='+sjleg)
                  if(sjleg>0){
                    gxhrcleg='1'
                  }
                  var scheduleid = curdata[index].scheduleid
                  if (curgxhscheduleid == scheduleid) {
                    curdata[index].currentdate = true
                  } else {
                    curdata[index].currentdate = false
                  }
                }
                that.setData({
                  gxhrcleg:gxhrcleg,
                  gxhrcMesg: curdata,
                  curgxhscheduleid: curgxhscheduleid
                });
              }, fail: res => {
                console.log(res, "error")
              }

            })


          } 
        }, fail: res => {
          console.log(res, "error")
        }
      })
    } else {
      wx.navigateTo({
        url: '../signInbyPhone/signIn'
      })
    }
  },
  gxhsc: function (e) {
    var that = this
    var eventid = e.currentTarget.dataset.tagid
    var curscheduleid = that.data.curscheduleid
    var curgxhscheduleid = that.data.curgxhscheduleid
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    console.log('exhibitionid=' + exhibitionid)
    console.log('u=' + u)
    if (!(exhibitionid=='0' && u=='0')) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/schedule/collection'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["eventid"] = eventid
      k["u"] = u
      var sign = app.globalData.picotoken + 'clientios' + 'eventid' + eventid + 'exhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          //从新加载数据刷新
          if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
            && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
             //默认最新（调用pico接口）
             var timestamp = Date.parse(new Date());
             timestamp = timestamp / 1000;
             var url = app.globalData.picoaddress + '/attendee/schedule/list'
             var k = {}
             k["v"] = '1.0.0'
             k["client"] = 'ios'
             k["timestamp"] = timestamp
             k["lan"] = 'cn'
             k["exhibitionid"] = exhibitionid
             k["u"] = u
 
             var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
             console.log(sign)
             var curb64 = md5.hexMD5(sign)
             console.log(curb64)
             k["sign"] = curb64
             wx.request({
               header: {
                 'content-type': 'application/x-www-form-urlencoded',
               },
               url: url,
               method: 'post',
               data: k,
               success(res) {
                 console.log(res)
                 var mesg = res.data
                 console.log('mesg=' + mesg)
                 var curdata = mesg.data
                 for (var index in curdata) {
                   var scheduleid = curdata[index].scheduleid
                   if (curscheduleid == scheduleid) {
                     curdata[index].currentdate = true
                   } else {
                     curdata[index].currentdate = false
                   }
                 }
                 that.setData({
                   rcMesg: curdata
                 });
               }, fail: res => {
                 console.log(res, "error")
               }
 
             })

            //加载个性化日程
            var gxhurl = app.globalData.picoaddress + '/attendee/schedule/mycollection'
            var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
            console.log(sign)
            var curb64 = md5.hexMD5(sign)
            console.log(curb64)
            k["sign"] = curb64
            wx.request({
              header: {
                'content-type': 'application/x-www-form-urlencoded',
              },
              url: gxhurl,
              method: 'post',
              data: k,
              success(res) {
                console.log(res)
                var mesg = res.data
                console.log('mesg=' + mesg)
                var curdata = mesg.data
                var gxhrcleg ='0' //默认为null
                for (var index in curdata) {
                  //判断个性化日程是否为null
                  var sjleg = curdata[index].eventgroup.length
                  console.log('sjleg='+sjleg)
                  if(sjleg>0){
                    gxhrcleg='1'
                  }
                  var scheduleid = curdata[index].scheduleid
                  if (curgxhscheduleid == scheduleid) {
                    curdata[index].currentdate = true
                  } else {
                    curdata[index].currentdate = false
                  }
                }
                that.setData({
                  gxhrcleg:gxhrcleg,
                  gxhrcMesg: curdata
                });
              }, fail: res => {
                console.log(res, "error")
              }

            })

          }
        }, fail: res => {
          console.log(res, "error")
        }
      })
    } else {
      wx.navigateTo({
        url: '../signInbyPhone/signIn'
      })
    }
  },
  livebro: function (e) {
    var that = this
    clearInterval(that.data.interval)
    var eventMesg = e.currentTarget.dataset.tagid
    var cureventMesgArray = eventMesg.split('_')
    var eventid = cureventMesgArray[0]
    var isappointment = cureventMesgArray[1]
    var livetime =  cureventMesgArray[2]
    //通过livetime截取截止日期
    var endtime = (livetime+'').substring(0,10)
    var curyear = (endtime.split('-'))[0]
    var curmonth = (endtime.split('-'))[1]
    var curday = (endtime.split('-'))[2]
    that.setData({
      curyear:curyear,
      curmonth:curmonth,
      curday:curday
    })
    console.log('endtime='+endtime)
    //var livetime = "2020-04-21 09:00:00"
 //   var cureventid = that.data.cureventid
    var serverTime = util.formatTime(new Date());
    that.startCountdown(serverTime,livetime);
   // var sfyyy= eventArray[1]
    if(isappointment=='true'){
      that.setData({
        sfyyshow:true,
        sfxyyyshow:false,
        cureventid:eventid
      })
    }else{
      that.setData({
        sfyyshow:true,
        sfxyyyshow:true,
        cureventid:eventid
      })
    }
      
  },
  cancle: function () {
    var that = this
    that.setData({
      sfyyshow:false,
    });
  },
  confirmyy: function () {
    var that = this
    var cureventid = that.data.cureventid
    console.log('cxszid='+cureventid)
    // var cxszid = cureventid.split('-')[0]+'-'+'1';
    //调用预约接口
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    console.log('exhibitionid=' + exhibitionid)
    console.log('u=' + u)
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
      && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/schedule/appointment'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["eventid"] = cureventid
      k["u"] = u

      var sign = app.globalData.picotoken + 'clientios'+'eventid'+cureventid+'exhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          that.setData({
            sfyyshow:false,
            yycgshow:true,
          });
        }, fail: res => {
          console.log(res, "error")
        }
      })
    } else {
      wx.redirectTo({
        url: '../signInbyPhone/signIn'
      })
    }
   
  },
  canclesuc: function () {
    var that = this
    var curscheduleid = that.data.curscheduleid
    var curgxhscheduleid = that.data.curgxhscheduleid
    var exhibitionid = wx.getStorageSync('exhibitionid')
    var u = wx.getStorageSync('u')
    console.log('exhibitionid=' + exhibitionid)
    console.log('u=' + u)
    if ((wx.getStorageSync('exhibitionid') || !"".trim() == wx.getStorageSync('exhibitionid'))
      && (wx.getStorageSync('u') || !"".trim() == wx.getStorageSync('u'))) {
      //默认最新（调用pico接口）
      var timestamp = Date.parse(new Date());
      timestamp = timestamp / 1000;
      var url = app.globalData.picoaddress + '/attendee/schedule/list'
      var k = {}
      k["v"] = '1.0.0'
      k["client"] = 'ios'
      k["timestamp"] = timestamp
      k["lan"] = 'cn'
      k["exhibitionid"] = exhibitionid
      k["u"] = u

      var sign = app.globalData.picotoken + 'clientiosexhibitionid' + exhibitionid + 'timestamp' + timestamp + app.globalData.picotoken
      console.log(sign)
      var curb64 = md5.hexMD5(sign)
      console.log(curb64)
      k["sign"] = curb64
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: url,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          for (var index in curdata) {
            var scheduleid = curdata[index].scheduleid
            if (curscheduleid == scheduleid) {
              curdata[index].currentdate = true
            } else {
              curdata[index].currentdate = false
            }
          }
          that.setData({
            rcMesg: curdata
          });
        }, fail: res => {
          console.log(res, "error")
        }

      })
      //加载个性化日程
      var gxhurl = app.globalData.picoaddress + '/attendee/schedule/mycollection'
      wx.request({
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        url: gxhurl,
        method: 'post',
        data: k,
        success(res) {
          console.log(res)
          var mesg = res.data
          console.log('mesg=' + mesg)
          var curdata = mesg.data
          var gxhrcleg ='0' //默认为null
          for (var index in curdata) {
            //判断个性化日程是否为null
            var sjleg = curdata[index].eventgroup.length
            console.log('sjleg='+sjleg)
            if(sjleg>0){
              gxhrcleg='1'
            }
            var scheduleid = curdata[index].scheduleid
            if (curgxhscheduleid == scheduleid) {
              curdata[index].currentdate = true
            } else {
              curdata[index].currentdate = false
            }
          }
          that.setData({
            gxhrcleg:gxhrcleg,
            gxhrcMesg: curdata
          });
        }, fail: res => {
          console.log(res, "error")
        }

      })
    } else {
      wx.redirectTo({
        url: '../signInbyPhone/signIn'
      })
    }
    that.setData({
      yycgshow:false
    });

  },
  toDetail: function (e) {
    var that = this;
    var tagid = e.currentTarget.dataset.tagid;
    console.log('tagid', tagid)
    wx.navigateTo({
      url: '../conferenceSchedule/activityDetails?eventid=' + tagid,
    })
  },
  //滑动切换
  swiperTab: function (e) {
    var that = this;
    that.setData({
      currentTab: e.detail.current
    });
  },
  //点击切换
  clickTab: function (e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  },
  onReady: function (e) {
    this.mapCtx = wx.createMapContext('myMap')
  },
  getCenterLocation: function () {
    this.mapCtx.getCenterLocation({
      success: function (res) {
        console.log(res.longitude)
        console.log(res.latitude)
      }
    })
  },
  tapPersonalDateSelect: function (e) {

    // console.log(e);
    var itemid = e.currentTarget.dataset.item || {};
    console.log(itemid)
  //  var personalDateSelectItems = this.data.personalDateSelectItems || [];
  //  for (var index in personalDateSelectItems) {
  //    var article = personalDateSelectItems[index];
 //     if (article.id == item.id) {
 //       article.active = true;
 //     }
 //     else{
 //       article.active = false;
  //    }
 //   }

    var that = this
    var gxhrcMesg = that.data.gxhrcMesg
    for (var index in gxhrcMesg) {
      var scheduleid = gxhrcMesg[index].scheduleid
      if (itemid == scheduleid) {
        gxhrcMesg[index].currentdate = true
      } else {
        gxhrcMesg[index].currentdate = false
      }
    }
    this.setData({
      gxhrcMesg: gxhrcMesg,
      curgxhscheduleid: itemid
    })
  },
  tapDateSelect: function (e) {
    var that = this
    var itemid = e.currentTarget.dataset.item || {};
  //  var dateSelectItems = this.data.dateSelectItems || [];
  //  for (var index in dateSelectItems) {
   //   var article = dateSelectItems[index];
  //    if (article.id == item.id) {
 //       article.active = true;
 //     }
  //    else{
 //       article.active = false;
 // //    }
   // }
    var rcMesg = that.data.rcMesg
    for (var index in rcMesg) {
      var scheduleid = rcMesg[index].scheduleid
      if (itemid == scheduleid){
         rcMesg[index].currentdate=true
        }else{
         rcMesg[index].currentdate = false
        }
    }
    this.setData({
      rcMesg: rcMesg,
      curscheduleid: itemid
    })
  },
})